package com.saret.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author biniam.gebremichael
 * @since 12/29/11
 */
public class StringUtils {

      public static String match(String candidate, String regex, Integer position) {
        Matcher matcher = Pattern.compile(regex).matcher(candidate);
        if (matcher.find()) {
            return matcher.group(position == null ? matcher.groupCount() : position);
        }
        return null;
    }
}
